/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mortbay.jetty.pico.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Hnmtuan
 */
@Entity
@Table(name = "item")
@NamedQueries({
    @NamedQuery(name = "Item.findAll", query = "SELECT i FROM Item i"),
    @NamedQuery(name = "Item.findByIdItem", query = "SELECT i FROM Item i WHERE i.itemPK.idItem = :idItem"),
    @NamedQuery(name = "Item.findByItemName", query = "SELECT i FROM Item i WHERE i.itemName = :itemName"),
    @NamedQuery(name = "Item.findByItemCode", query = "SELECT i FROM Item i WHERE i.itemCode = :itemCode"),
    @NamedQuery(name = "Item.findByItemState", query = "SELECT i FROM Item i WHERE i.itemState = :itemState"),
    @NamedQuery(name = "Item.findByItemPrice", query = "SELECT i FROM Item i WHERE i.itemPrice = :itemPrice"),
    @NamedQuery(name = "Item.findByItemDiscount", query = "SELECT i FROM Item i WHERE i.itemDiscount = :itemDiscount"),
    @NamedQuery(name = "Item.findByCategory", query = "SELECT i FROM Item i WHERE i.itemPK.category = :category"),
    @NamedQuery(name = "Item.findByItemQuantity", query = "SELECT i FROM Item i WHERE i.itemQuantity = :itemQuantity"),
    @NamedQuery(name = "Item.findByItemNew", query = "SELECT i FROM Item i WHERE i.itemNew = :itemNew"),
    @NamedQuery(name = "Item.findByCreatedDate", query = "SELECT i FROM Item i WHERE i.createdDate = :createdDate")})
public class Item implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ItemPK itemPK;
    @Column(name = "ItemName")
    private String itemName;
    @Column(name = "ItemCode")
    private String itemCode;
    @Lob
    @Column(name = "ItemBDescription")
    private String itemBDescription;
    @Column(name = "ItemState")
    private Integer itemState;
    @Column(name = "ItemPrice")
    private Float itemPrice;
    @Column(name = "ItemDiscount")
    private String itemDiscount;
    @Lob
    @Column(name = "ItemMDescription")
    private String itemMDescription;
    @Lob
    @Column(name = "ItemFields")
    private String itemFields;
    @Column(name = "ItemQuantity")
    private Integer itemQuantity;
    @Column(name = "ItemNew")
    private Boolean itemNew;
    @Column(name = "CreatedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "item1")
    private List<Saved> savedList;
    @JoinColumn(name = "Category", referencedColumnName = "idCate", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Category category1;
    @JoinColumn(name = "Location", referencedColumnName = "idLocal")
    @ManyToOne(optional = false)
    private Location location;
    @JoinColumn(name = "Manufacturer", referencedColumnName = "idManu")
    @ManyToOne(optional = false)
    private Manufacturer manufacturer;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "item")
    private List<Images> imagesList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "item")
    private List<Orderdetail> orderdetailList;

    public Item() {
    }

    public Item(ItemPK itemPK) {
        this.itemPK = itemPK;
    }

    public Item(String idItem, String category) {
        this.itemPK = new ItemPK(idItem, category);
    }

    public ItemPK getItemPK() {
        return itemPK;
    }

    public void setItemPK(ItemPK itemPK) {
        this.itemPK = itemPK;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public String getItemCode() {
        return itemCode;
    }

    public void setItemCode(String itemCode) {
        this.itemCode = itemCode;
    }

    public String getItemBDescription() {
        return itemBDescription;
    }

    public void setItemBDescription(String itemBDescription) {
        this.itemBDescription = itemBDescription;
    }

    public Integer getItemState() {
        return itemState;
    }

    public void setItemState(Integer itemState) {
        this.itemState = itemState;
    }

    public Float getItemPrice() {
        return itemPrice;
    }

    public void setItemPrice(Float itemPrice) {
        this.itemPrice = itemPrice;
    }

    public String getItemDiscount() {
        return itemDiscount;
    }

    public void setItemDiscount(String itemDiscount) {
        this.itemDiscount = itemDiscount;
    }

    public String getItemMDescription() {
        return itemMDescription;
    }

    public void setItemMDescription(String itemMDescription) {
        this.itemMDescription = itemMDescription;
    }

    public String getItemFields() {
        return itemFields;
    }

    public void setItemFields(String itemFields) {
        this.itemFields = itemFields;
    }

    public Integer getItemQuantity() {
        return itemQuantity;
    }

    public void setItemQuantity(Integer itemQuantity) {
        this.itemQuantity = itemQuantity;
    }

    public Boolean getItemNew() {
        return itemNew;
    }

    public void setItemNew(Boolean itemNew) {
        this.itemNew = itemNew;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public List<Saved> getSavedList() {
        return savedList;
    }

    public void setSavedList(List<Saved> savedList) {
        this.savedList = savedList;
    }

    public Category getCategory1() {
        return category1;
    }

    public void setCategory1(Category category1) {
        this.category1 = category1;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public Manufacturer getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(Manufacturer manufacturer) {
        this.manufacturer = manufacturer;
    }

    public List<Images> getImagesList() {
        return imagesList;
    }

    public void setImagesList(List<Images> imagesList) {
        this.imagesList = imagesList;
    }

    public List<Orderdetail> getOrderdetailList() {
        return orderdetailList;
    }

    public void setOrderdetailList(List<Orderdetail> orderdetailList) {
        this.orderdetailList = orderdetailList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemPK != null ? itemPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Item)) {
            return false;
        }
        Item other = (Item) object;
        if ((this.itemPK == null && other.itemPK != null) || (this.itemPK != null && !this.itemPK.equals(other.itemPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.mortbay.jetty.pico.entities.Item[itemPK=" + itemPK + "]";
    }

}
